{% do script(['videoactivity/js/show/index.js']) %}
{% set video = activity.ext|prepare_video_media_uri %}

{% if activity.watchStatus.status == 'error' %}
  <div class="iframe-parent-content iframe-parent-full" id="video-content" data-role="lesson-content">
    <div class="alert alert-danger mv20 mh20">
      <i class="es-icon es-icon-info"></i>
      {{ 'course.activity.video.beyond_watch_limit_tip'|trans({'%watchedTime%': activity.watchStatus.watchLimitTime|duration_text, '%watchLimit%': (activity.watchStatus.watchLimitTime / activity.length)|round}) }}
    </div>
  </div>
{% elseif video.mediaSource|default('self') == 'self' %}
  {% if video.file|default(null) %}
    <div class="iframe-parent-content iframe-parent-full" id="video-content"
         data-role="lesson-content"
         data-watch-url="{{ path('course_acitvity_watch',{courseId: activity.fromCourseId, id: activity.id}) }}"
         data-id="{{ activity.id }}"
         data-watch-time-sec="{{ setting('magic.watch_time_sec')|default(60) }}"
         data-finish-type="{{ activity.finishType|default('') }}"
         data-finish-data="{{ activity.finishData|default('') }}">
      {#  如果用户上次观看过视频，需要请求上次的视频时长 作为参数 starttime= xxx #}
      {{ render(controller('AppBundle:Player:show', {id: video.mediaId, isPart: true, context: {activityId: activity.id }, file:activity.ext.file|default('')})) }}
    </div>
  {% else %}
    <div class="iframe-parent-content iframe-parent-full" id="video-content" data-role="lesson-content">
      {% include 'activity/file-not-found.html.twig' with {type:'video'} %}
    </div>
  {% endif %}
{% elseif video.mediaSource|default('self') == 'iframe' %}
  <div id="task-preview-iframe" class="iframe-parent-content iframe-parent-full">
    <iframe src="{{ video.mediaUri }}" style="height:100%; width:100%; border:0px; overflow: hidden"
            scrolling="no"></iframe>
  </div>
{% else %}
  <div class="dashboard-body">
    <div class="iframe-parent-content iframe-parent-full" id="video-content" data-role="lesson-content"
         data-media-source="{{ video.mediaSource }}"
         style="position:absolute;top:0;bottom:0;left:0;right:0;text-align:center;">
      {% if activity.ext.mediaSource == 'NeteaseOpenCourse' and activity.content is not empty %}
        <div style="position:absolute;top:0;bottom:0;left:0;right:0;" id="local-video-player">
          <div id="lesson-video-content" data-url="{{ activity.ext.mediaUri }}" class="local-video-player "
               style="height: 100%"></div>
        </div>

      {% else %}
        <iframe src="{{ activity.ext.mediaUri }}" style="height:100%; width:100%; border:0; overflow: hidden"
                scrolling="no"></iframe>
      {% endif %}
    </div>
  </div>
{% endif %}
